package org.batatasframework.support.database.metadatas;

import org.batatasframework.support.database.FieldFormatSetter;

public abstract class AbstractFieldMetadata<Table extends TableMetadata> implements FieldMetadata, FieldFormatSetter{
	protected final Table tableMetadata;
	
	/*
	 * 数据库里定义的原始的排序的位置，可能会比较重要
	 */
	protected int ordinal;
	/**
	 * 名称，可用于界面上的显示，也可以不用
	 */
	protected String title;
	protected Object format;

	public AbstractFieldMetadata(Table tableMetadata){
		this.tableMetadata = tableMetadata;
	}
	
	@Override
	public boolean hasFormate() {
		return null != format;
	}

	@Override
	public void setFormat(Object format){
		if(null != format) this.format = format;
	}
	
	@Override
	public Object getFormat() {
		return format;
	}
	
	@Override
	public String getTitle() {
		return title;
	}

	@Override
	public int getOrdinal() {
		return ordinal;
	}
	
	@Override
	public Table getTableMetadata() {
		return tableMetadata;
	}
	
	//各种set
	public FieldMetadata setOrdinal(int ordinal) {
		this.ordinal = ordinal;
		return this;
	}
	
	public FieldMetadata setTitle(String title) {
		this.title = title;
		return this;
	}
}
